package com.ktc.qa.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.ktc.qa.pojo.Problem;
import org.springframework.data.jpa.repository.Query;

/**
 * @Description 问题 数据访问接口
 * @date 2021-04-12 10:49:44
 */
public interface ProblemDao extends JpaRepository<Problem, String>, JpaSpecificationExecutor<Problem> {

    @Query("select p from Problem p where p.id in (select pl.problemid from Pl pl where pl.labelid=?1) order by p.createtime desc ")
    Page<Problem> newlist(String labelid, Integer page, Integer size, Pageable of);

    @Query("select p from Problem p where p.id in (select pl.problemid from Pl pl where pl.labelid=?1) order by p.reply desc ")
    Page<Problem> hotlist(String labelid, Integer page, Integer size, Pageable of);

    @Query("select p from Problem p where p.id in (select pl.problemid from Pl pl where pl.labelid=?1) and p.reply=0 order by p.createtime desc ")
    Page<Problem> waitlist(String labelid, Integer page, Integer size, Pageable of);
}

